﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _02Test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }


    protected void Button1_Click(object sender, EventArgs e)
    {

        int n = 0;
        try
        {
            n = int.Parse(TextBox1.Text.ToString());
            int s = 0;
            if (n <= 2)
            {
                s = 1;
            }
            else
            {
                int s1 = 1;
                int s2 = 1;
                for (int i = 2; i < n - 1; i++)
                {
                    s2 = s1 + s2;
                    s1 = s2 - s1;
                }
                s = s1 + s2;
            }

            Label2.Text = ("斐波那契数列第n项为:" + s);
        }
        catch (Exception ec)
        {
            Response.Write("请输入正确的数值");
        }


    }
}